package com.example.plusz.controller;

import com.example.plusz.entity.Clazz;
import com.example.plusz.service.ClazzService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @ClassName ClazzController
 * @Description TODO
 * @Author HP
 * @Date 16:18 2022/7/21
 * @Version 1.0
 **/
@RestController
@RequestMapping("/clazz")
public class ClazzController {
    @Autowired
    private ClazzService clazzService;
    //查询所有班级信息
    @RequestMapping("/findAll")
    public List<Clazz> findAllClazz() {

        return clazzService.list(null);
    }
    //通过id查询班级
    @RequestMapping("/findById")
    public Clazz findClazzById(@RequestParam Long id) {

        return clazzService.getById(id);
    }
    //添加班级信息
    @RequestMapping("/save")
    public boolean saveClazz(@RequestBody Clazz clazz) {

        return clazzService.save(clazz);
    }
    //修改班级信息
    @RequestMapping("/update")
    public boolean updateClazzById(@RequestBody Clazz clazz) {

        return clazzService.updateById(clazz);
    }
    //根据id删除班级
    @RequestMapping("/removeById")
    public boolean removeClazz(@RequestParam Long id) {

        return clazzService.removeById(id);
    }

    @RequestMapping("/removeByIds")
    public boolean removeClazzByIds(@RequestBody List<Integer> ids) {

        return clazzService.removeByIds(ids);
    }
}
